package com.my.interview.proxy.cglib_proxy;

import net.sf.cglib.proxy.Enhancer;

/**
 * 动态代理使用
 **/
public class CGLibProxyDriver {

    public static void main(String[] args) {

        Enhancer enhancer = new Enhancer();
        //指定要代理的目标对象
        enhancer.setSuperclass(WaitForProxy.class);
        //处理代理逻辑的对象
        enhancer.setCallback(new DynamicProxy());
        //动态创建代理对象
        WaitForProxy waitForProxy = (WaitForProxy) enhancer.create();
        waitForProxy.sayHelloToCGLib();
    }
}
